// -----------------------------------------------------------------------
// <copyright file="FileSystem.cs" company="Company">
// Company GmbH (R) 2011
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Linq;
using System.Text;
using Company.IO.Interfaces;

namespace Company.IO
{
    /// <summary>
    /// Encapsulate the access to the FileSystem
    /// </summary>
    public class FileSystem : FileSystemTemplate<IDirectory, IPath, IFile>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FileSystem"/> class.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="path">The path.</param>
        /// <param name="file">The file.</param>
        public FileSystem(IDirectory directory, IPath path, IFile file)
            : base(directory, path, file)
        {
        }

        /// <summary>
        /// Normalizes the directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>the normalizated path</returns>
        protected override string NormalizeDirectory(string path)
        {
            var stringBuilder = new StringBuilder();
            stringBuilder.Append(Path.GetInvalidPathChars());
            return Path.GetFullPath(path.Replace(stringBuilder.ToString(), "_"));
        }
    }
}